package com.example;

import com.example.config.SpringConfig3;
import com.example.config.SpringConfig4;
import org.junit.Test;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.core.env.ConfigurableEnvironment;


public class MainTest2 {
    @Test
    public void main2() {
        AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(SpringConfig3.class);
        String[] definitionNames = context.getBeanDefinitionNames();
        context.close();
    }

    @Test
    public void main3() {
        AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(SpringConfig4.class);
        String[] definitionNames = context.getBeanDefinitionNames();

        //从运行环境读取加载到运行环境中的属性和值
        ConfigurableEnvironment environment = context.getEnvironment();
        String property = environment.getProperty("person.lastname");

        Object person = context.getBean("person");
        context.close();
    }
}




